<% layout('layout/layout') %>
<% block('header').append(`<style>
</style>`)%>
<div id="pages" class="row">
  <div class="col-xs-12">
    <div class="box">
      <div class="box-header">
        <h3 class="box-title">字典管理</h3>
        <div class="box-tools">
          <a class="btn  btn-sm btn-success" href="add">添加+</a>
          <a id="clearBuffer" class="btn  btn-sm btn-primary" href="javascript:void(0)">清空缓存</a>
          <!--<div class="input-group input-group-sm" style="width: 150px;">-->
          <!--<input type="text" name="table_search" class="form-control pull-right" placeholder="Search">-->

          <!--<div class="input-group-btn">-->
          <!--<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>-->
          <!--</div>-->
          <!--</div>-->
        </div>
      </div>
      <!-- /.box-header -->
      <div class="box-body table-responsive no-padding">
        <table class="table table-bordered table-hover">
          <tbody>
          <tr>
            <th>属性</th>
            <th>属性名</th>
            <th>是否有效</th>
            <th>分组</th>
            <th>操作</th>
          </tr>
          <% dicts.forEach(function(item){%>
          <tr>
            <td><%=item.name%></td>
            <td><%=item.nameCn%></td>
            <td><%=item.isValid ?'有效':'无效'%></td>
            <td><%=item.group || '无' %></td>
            <td>
              <% if(item.valueType !=='other') { %>
              <a class="btn  btn-sm btn-success" href="field/<%=item.name %>">属性修改</a>
              <% } %>
              <a class="btn  btn-sm btn-success" href="add?update=<%=item._id %>">修改</a>
              <a class="btn btn-delete  btn-sm btn-danger" data-id="<%=item._id%>" data-url="<%=assetsPath %>/dict/delete" href="javascript:void(0)">删除</a>
            </td>
          </tr>
          <% }) %>
          </tbody>
        </table>
      </div>
      <!-- /.box-body -->
    </div>
    <!-- /.box -->
    <div class="j_pager" data-page="<%=page %>"  data-count="<%=count || 1 %>"></div>
  </div>

</div>
<% block('footer').append(`<script src="${assetsPath}/js/uploadImg.js"></script>`); %>
<% block('footer').append(`<script src="${assetsPath}/js/jPager.js" ></script>`); %>
<% block('footer').append(`<script>
    jQuery(function() {
    	$('.j_pager').pager()
    	$.delBtn('#pages','你确定要删掉这个页面么')
    	$('#clearBuffer').on('click',function () {
    		$.post('/admin/clearCache').done(function(res) {
    			$.alert('清除缓存成功～')
    		})
    	})
    })

</script>`)%>